//
//  ThemeLabel.m
//  ThemeManager
//
//  Created by weiguang on 2017/1/13.
//  Copyright © 2017年 weiguang. All rights reserved.
//

#import "ThemeLabel.h"

@implementation ThemeLabel

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        
        [self setColor];
        [self setTextFont];
        
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(themeColorNotification:)
         name:kThemeColorChangeNotification object:nil];
        
        [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(themeFontNotification:)
         name:kThemeFontChangeNotification object:nil];

    }
    
    return self;
}

- (void)setColor{
    self.textColor = [[ThemeManger shareInstance] getThemeColor];
}

- (void)setTextFont{
    self.font = [UIFont systemFontOfSize:[[ThemeManger shareInstance] getThemeFont]];
}

-(void)themeColorNotification:(NSNotification *)not{
    [self setColor];
}

-(void)themeFontNotification:(NSNotification *)not{
    
    [self setTextFont];
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:kThemeFontChangeNotification];
    [[NSNotificationCenter defaultCenter] removeObserver:kThemeColorChangeNotification];
}

@end
